/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package report.committeeMembersAddressList;

import template.DefaultReportForm;
import template.RegistrantionPanel;
import zobject.Year;

/**
 *
 * @author User
 */
public class REPCommitteeMembersAddressList extends DefaultReportForm {

    @Override
    public RegistrantionPanel objectCreator() {
        registrantionPanel = new PCCommitteeMembersAddressList();
        return registrantionPanel;
    }

    @Override
    public Object initObject(RegistrantionPanel panel) {
        
        return panel.initObject();
    }

    @Override
    protected String setFrameTitle() {
        return FRAME_TITLE;
    }

    @Override
    protected String setReportTitle() {
        return genarateReportTitle();
    }

    @Override
    protected String setReport() {
        return REPORT;
    }

    @Override
    protected String setQuery() {
        return genarateQuery();
    }

    private static final String FRAME_TITLE = "report";
    private static RegistrantionPanel registrantionPanel;
    private static final String REPORT = "AddressListReport.jasper";

    private String genarateQuery() {
        return "		member.name,\n"
                + "		member.address_line_1,\n"
                + "		member.address_line_2,\n"
                + "		member.address_line_3\n"
                + "from\n"
                + "		member\n"
                + "		left join year_committee on year_committee.member = member.code\n"
                + "where\n"
                + "		member.`status` = 'ACTIVE' and"
                + "             year_committee.status <> 'SUSPEND' and"
                + "             year_committee.year = '"+ ((Year)initObject(registrantionPanel)).getCode()+"'";
    }

    private String genarateReportTitle() {
        return "Address List of Committee Members - " + initObject(registrantionPanel).toString();
    }
}
